package com.sykj.springboot.test.designMode.Observer1;

public class Watch extends Thread {

    private HanFeiZi hanFeiZi;
    private LiSi liSi;
    private String type;

    public Watch(HanFeiZi hanFeiZi, LiSi liSi, String type) {
        this.hanFeiZi = hanFeiZi;
        this.liSi = liSi;
        this.type = type;
    }

    @Override
    public void run() {
        while (true){
            if (type.equals("breakfast")){
                if (hanFeiZi.isBreakfastFlag()){
                    liSi.update("韩非子在吃早饭");
                    hanFeiZi.setBreakfastFlag(false);
                }
            }else{
                if (hanFeiZi.isHaveFunFlag()){
                    liSi.update("韩非子在娱乐");
                    hanFeiZi.setHaveFunFlag(false);
                }
            }
        }
    }
}
